#ifndef FACEBOOKLOGINDIALOG_H
#define FACEBOOKLOGINDIALOG_H

#ifdef BUILD_WITH_FACEBOOK

#include <QtGui/QDialog>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkCookieJar>

#include <QtCore/QDebug>

#include "ui_FacebookLoginDialog.h"

#include "CustomCookieJar.h"

class FacebookLoginDialog : public QDialog
{
Q_OBJECT

public:
	FacebookLoginDialog(QWidget* parent = 0, Qt::WFlags flags = 0);
	~FacebookLoginDialog();

	void initAndShow();

	void init();

	const QString& sessionKey() { return m_sessionKey; }
	const QString& uid() { return m_uid; }
	const QString& secret() { return m_secret; }

	virtual void closeEvent(QCloseEvent* event);
	virtual void hideEvent(QHideEvent* event);

public slots:
	void loadProgress(int);
	void loadStarted();
	void loadFinished(bool);
	void message(const QString&);

	void urlDidChange(const QUrl&);

signals:
	void done();

private:
	Ui::FBLoginDialog ui;

	QNetworkAccessManager* m_manager;
	CustomCookieJar* m_cookieJar;

	QString m_sessionKey;
	QString m_uid;
	QString m_secret;
};

#endif

#endif